﻿using Microsoft.EntityFrameworkCore;
using Shop.Application.Orders.Dto;
using Shop.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shop.Application.Orders
{
    public class GetOrderByOrderID
    {
        private DBContext _context;

        public GetOrderByOrderID(DBContext context)
        {
            _context = context;
        }

        public OrderDto Do(Guid id) =>
           _context.Orders.Where(x => x.OrderID == id)
                .Select(y => new OrderDto
                {
                    OrderName=y.OrderName,
                    UserName = y.UserName,
                    Email = y.Email,
                    PhoneNumber = y.PhoneNumber,
                    Address = y.Address,
                    City = y.City,
                    PostCode = y.PostCode
                })
                .FirstOrDefault();
    }
}
